package org.dromara.common.core.utils;

/**
 * 描述：
 *
 * @Author: lbc
 * @Date: 2023-07-28 15:44
 * @email: 594599620@qq.com
 * @Description: keep coding
 */
public class SessionUtil {

    public static final String TEMPLATE_IDENTITY = "%s:%s";

    /**
     * 生成 userNo + deviceType
     * 用户登录的设备
     *
     * @param userId
     * @param instanceId
     * @return
     */
    public static String binding(String userId, String instanceId) {
        return String.format(TEMPLATE_IDENTITY, userId, instanceId);
    }

    /**
     * 没有做校验
     * @param identityNo
     * @return
     */
    public static String getUserId(String identityNo) {
        String[] split = identityNo.split(":");
        if (split.length <= 0) {
            return null;
        }
        return  split[0];
    }

    /**
     * 没有做校验
     *
     * @param identityNo
     * @return
     */
    public static String getInstanceId(String identityNo) {
        String[] split = identityNo.split(":");
        if (split.length <= 0) {
            return null;
        }
        return  split[1] ;
    }

}
